home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / cexpress / keyboard / flterout.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-03  |  3.0 KB  |  99 lines

  1. ;char  filter_out(ascii_string,extended_string);
  2. ;  char  *ascii_string,*extended_string;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _error_code:byte
  6.     EXTRN  _beep_on:byte
  7.  
  8. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  9.     ASSUME CS:_TEXT
  10.     PUBLIC _filter_out
  11. _filter_out proc near
  12.     push bp            ;
  13.     mov  bp,sp        ;set up stack frame
  14.     push di            ;
  15.     cmp  _memory_model,0    ;near or far?
  16.     jle  A1            ;jump if near
  17.     inc  bp            ;else add 2 to BP
  18.     inc  bp            ;
  19. A1:    mov  _error_code,0    ;0 = ASCII code
  20.     mov  ax,ds        ;make ES = DS for NEAR case
  21.     mov  es,ax        ;
  22.     cmp  _memory_model,2    ;data near or far?
  23.     jb   L0            ;
  24.     les  di,dword ptr[bp+4] ;ES:DI pts to ASCIIString
  25.     jmp  short L00        ;
  26. L0:    mov  di,[bp+4]        ;near case
  27. L00:    sub  ah,ah        ;function to read key
  28.     int  16h        ;wait for a keystroke
  29.     or   al,al        ;extended code?
  30.     jnz  B1            ;jump ahead if not
  31.     inc  _error_code    ;1 = extended code
  32.     mov  al,ah        ;move 2nd byte to AL
  33.     cmp  _memory_model,2    ;again, near or far?
  34.     jb   L000        ;
  35.     les  di,dword ptr[bp+8] ;ES:DI pts to ExtendedString
  36.     jmp  short B1        ;
  37. L000:    mov  di,[bp+6]        ;
  38. B1:    mov  ch,es:[di]        ;string length to CH
  39.     inc  ch            ;adjust for loop entry
  40.     mov  dl,al        ;place char in DL
  41.     cmp  dl,8        ;is it the backspace key?
  42.     jne  C1            ;jump ahead if not
  43.     cmp  ah,14        ;Scan code for backspace
  44.     je   F1            ;jump ahead if single key
  45.     mov  dl,208        ;208 signals Ctrl-H
  46. C1:    cmp  dl,9        ;is it the tab key?
  47.     jne  D1            ;jump ahead if not
  48.     cmp  ah,15        ;Scan code for tab key
  49.     je   F1            ;jump ahead if single key
  50.     mov  dl,209        ;209 signals Ctrl-I
  51. D1:    cmp  dl,13        ;is it the return key?
  52.     jne  E1            ;jump ahead if not
  53.     cmp  ah,28        ;Scan code for Return key
  54.     je   F1            ;jump ahead if single key
  55.     mov  dl,213        ;213 signals Ctrl-M
  56. E1:    cmp  dl,27        ;is it the escape key?
  57.     jne  F1            ;jump ahead if not
  58.     cmp  ah,1        ;Scan code for Esc key
  59.     je   F1            ;jump ahead if single key
  60.     mov  dl,227        ;227 signals Ctrl-[
  61. F1:    mov  al,es:[di]        ;get the character
  62.     inc  di            ;forward string pointer
  63.     cmp  al,0        ;test for end of string
  64.     je   K1            ;
  65.     cmp  al,0FFH        ;test if all chars excluded
  66.     je   G1            ;loop if so
  67.     cmp  al,es:[di]        ;is next char the same?
  68.     je   I1            ;jump to range routine
  69.     cmp  al,dl        ;does char match?
  70.     jne  F1            ;if not, go try the next
  71. G1:    mov  ah,2        ;char found, beep and reject it
  72.     mov  dl,7        ;beep character
  73.     cmp  _beep_on,0        ;test if beep enabled
  74.     je   H1            ;jump if not
  75.     int  21h        ;beep! wrong key
  76. H1:    jmp  A1            ;go try next keystroke
  77. I1:    inc  di            ;start char range check
  78.     sub  ch,2        ;adjust strg len counter
  79.     mov  bl,es:[di]        ;get character
  80.     inc  di            ;forward string pointer
  81.     cmp  al,bl        ;compare 2 chars in range
  82.     jb   J1            ;jump if AL lower
  83.     xchg al,bl        ;else exchg the 2 values
  84. J1:    cmp  dl,al        ;cmp input to low char
  85.     jb   F1            ;out of range if below
  86.     cmp  dl,bl        ;cmp input to high char
  87.     ja   F1            ;out of range if above
  88.     jmp  short G1        ;go beep and try again
  89. K1:    mov  al,dl        ;set char for return
  90.     pop  di            ;
  91.     pop  bp            ;
  92.     cmp  _memory_model,0    ;quit
  93.     jle  quit        ;
  94.     db   0CBh        ;RET far
  95. quit:    ret            ;RET near
  96. _filter_out ENDP
  97. _TEXT    ENDS
  98.     END
  99.